﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package org.aswing.resizer {
    import flash.events.*;
    import org.aswing.*;
    import org.aswing.event.*;

    public class DefaultResizeBarHandler {

        private var resizer:DefaultResizer;
        private var mc:AWSprite;
        private var arrowRotation:Number;
        private var strategy:ResizeStrategy;

        public function DefaultResizeBarHandler(_arg1:DefaultResizer, _arg2:AWSprite, _arg3:Number, _arg4:ResizeStrategy){
            this.resizer = _arg1;
            this.mc = _arg2;
            this.arrowRotation = _arg3;
            this.strategy = _arg4;
            this.handle();
        }
        public static function createHandler(_arg1:DefaultResizer, _arg2:AWSprite, _arg3:Number, _arg4:ResizeStrategy):DefaultResizeBarHandler{
            return (new DefaultResizeBarHandler(_arg1, _arg2, _arg3, _arg4));
        }

        private function handle():void{
            this.mc.addEventListener(MouseEvent.ROLL_OVER, this.__onRollOver);
            this.mc.addEventListener(MouseEvent.ROLL_OUT, this.__onRollOut);
            this.mc.addEventListener(MouseEvent.MOUSE_DOWN, this.__onPress);
            this.mc.addEventListener(MouseEvent.MOUSE_UP, this.__onUp);
            this.mc.addEventListener(MouseEvent.CLICK, this.__onRelease);
            this.mc.addEventListener(ReleaseEvent.RELEASE_OUT_SIDE, this.__onReleaseOutside);
            this.mc.addEventListener(Event.REMOVED_FROM_STAGE, this.__onDestroy);
        }
        private function __onRollOver(_arg1:MouseEvent):void{
            if (((!(this.resizer.isResizing())) && ((((_arg1 == null)) || (!(_arg1.buttonDown)))))){
                this.resizer.startArrowCursor();
                this.__rotateArrow();
                if (this.mc.stage){
                    this.mc.stage.addEventListener(MouseEvent.MOUSE_MOVE, this.__rotateArrow, false, 0, true);
                };
            };
        }
        private function __onRollOut(_arg1:MouseEvent):void{
            if (((!(this.resizer.isResizing())) && (!(_arg1.buttonDown)))){
                if (this.mc.stage){
                    this.mc.stage.removeEventListener(MouseEvent.MOUSE_MOVE, this.__rotateArrow);
                };
                this.resizer.stopArrowCursor();
            };
        }
        private function __onPress(_arg1:MouseEvent):void{
            this.resizer.setResizing(true);
            this.startResize(_arg1);
            if (this.mc.stage){
                this.mc.stage.removeEventListener(MouseEvent.MOUSE_MOVE, this.__rotateArrow);
                this.mc.stage.addEventListener(MouseEvent.MOUSE_MOVE, this.resizing, false, 0, true);
            };
        }
        private function __onUp(_arg1:MouseEvent):void{
            this.__onRollOver(null);
        }
        private function __onRelease(_arg1:Event):void{
            this.resizer.setResizing(false);
            this.resizer.stopArrowCursor();
            if (this.mc.stage){
                this.mc.stage.removeEventListener(MouseEvent.MOUSE_MOVE, this.resizing);
            };
            this.finishResize();
        }
        private function __onReleaseOutside(_arg1:Event):void{
            this.__onRelease(_arg1);
        }
        private function __onDestroy(_arg1:Event):void{
            this.mc.stage.removeEventListener(MouseEvent.MOUSE_MOVE, this.resizing);
            this.mc.stage.removeEventListener(MouseEvent.MOUSE_MOVE, this.__rotateArrow);
        }
        private function __rotateArrow(_arg1:Event=null):void{
            this.resizer.setArrowRotation(this.arrowRotation);
        }
        private function startResize(_arg1:MouseEvent):void{
            this.resizer.startResize(this.strategy, _arg1);
        }
        private function resizing(_arg1:MouseEvent):void{
            this.resizer.resizing(this.strategy, _arg1);
        }
        private function finishResize():void{
            this.resizer.finishResize(this.strategy);
        }

    }
}//package org.aswing.resizer 
